package edu.drexel.jrexel2d.objects2D;

import java.io.Serializable;

public class Point2D implements Serializable {
	private float x;
	private float y;

	public Point2D(int x, int y) {
		this.x = x;
		this.y = y;
	}
	
	public Point2D(float x, float y) {
		this.x = x;
		this.y = y;
	}

	public Point2D(Point2D p, int x, int y) {
		this.x = p.getX() + x;
		this.y = p.getY() + y;
	}
	
	public Point2D(Point2D p, float x, float y) {
		this.x = p.getXF() + x;
		this.y = p.getYF() + y;
	}
	
	public Point2D(String s1, String s2) {
		this.x = Integer.parseInt(s1) ;
		this.y = Integer.parseInt(s2) ;
	}
	
	public Point2D(Point2D p1, Point2D p2) {
		this.x = p2.getX() - p1.getX();
		this.y = p2.getY() - p1.getY();
	}

	public int getX() {
		return (int)x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getY() {
		return (int)y;
	}
	
	public float getXF() {
		return x;
	}

	public void setXF(float x) {
		this.x = x;
	}

	public void setYF(float y) {
		this.y = y;
	}

	public float getYF() {
		return y;
	}
	
	public void shift(int x, int y) {
		this.x += x;
		this.y += y;
	}

	public void shiftF(float x, float y) {
		this.x += x;
		this.y += y;
	}
	
	public float cross(Point2D p) {	// Compute cross product of this and p
		return (this.x * p.getYF()) - (this.y * p.getXF());
	}

}
